home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
A.C.E. 2
/
ACE CD 2.iso
/
FILES
/
UTILS
/
GAMESDS3.DMS
/
GAMESDS3.adf
/
GDS_Examples.lha
/
Examples
/
sound
/
snd_na_left.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-11-14
|
4KB
|
132 lines
/* this version does not allocate the Amiga sound channels in a system
friendly way. It just uses 'em.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dos.h>
#include <signal.h>
#include <proto/exec.h>
#include <GameSmith:include/libraries/libraries.h>
#include <GameSmith:include/libraries/libptrs.h>
#include <GameSmith:include/sound/sound.h>
#include <GameSmith:include/proto/all.h>
void ctrl_c(int);
struct sound_struct sample;
int stop=0; /* ctrl-C break flag */
/***************************************************************************/
main(argc,argv)
int argc;
char *argv[];
{
int err,echo,temp,old_prio;
if (argc < 2)
{
printf("\nUsage: SND file_name [loop value] [echo divisor] [volume cnt]\n");
printf(" [volume decrement] [period cnt] [period decrement] [period]\n");
exit(01);
}
signal(SIGINT,&ctrl_c); /* set up break handler ANSI style */
sample.flags=SND_FAST; /* load sample to Fast RAM if available */
if (gs_open_libs(DOS|GRAPHICS,0)) /* need DOS for reading file, and Graphics */
exit(02); /* sound sys uses Graphics lib to determine */
/* whether a PAL or NTSC machine for timing */
if (err=gs_load_iff_sound(&sample,NULL,argv[1]))
{
if (err == -4) /* If not IFF, try to load raw */
{
if (err=gs_load_raw_sound(&sample,argv[1]))
{
printf("\nError loading raw sample. Code = %d\n",err);
gs_close_libs();
exit(03);
}
else
printf("\n%s - Raw Sample\n\n",argv[1]);
}
else if (err == -7) /* if couldn't load 2nd channel */
{
printf("\nUnable to load 2nd sound channel for stereo play\n");
}
else
{
printf("\nError loading IFF sample. Code = %d\n",err);
gs_close_libs();
exit(03);
}
}
else
{
printf("\n%s - IFF 8SVX Sample\n\n",argv[1]);
}
if (argc >= 3) /* check for repeat value */
{
sample.repeat=atoi(argv[2]);
}
if (argc >= 4) /* check for echo divisor */
{
echo=atoi(argv[3]);
if (echo > 1)
{
temp=sample.length/echo;
if (temp)
{
sample.loop=sample.data+((sample.length-temp)*2);
}
}
}
if (argc >= 5) /* check for volume count */
{
sample.volcnt=atoi(argv[4]);
}
if (argc >= 6) /* check for volume decrement */
{
sample.volfade=atoi(argv[5]);
}
if (argc >= 7) /* check for period count */
{
sample.percnt=atoi(argv[6]);
}
if (argc >= 8) /* check for period decrement */
{
sample.perfade=atoi(argv[7]);
}
if (argc >= 9) /* check for new period value */
{
sample.period=atoi(argv[8]);
}
if (gs_open_sound(0,0,0,(4096/2))) /* open sound system, don't alloc channels */
{
gs_free_sound(&sample);
printf("\nError opening sound system\n");
gs_close_libs();
exit(04);
}
gs_start_sound(&sample,CHANNEL0); /* start left channel playing */
old_prio=gs_task_prio(-128); /* lowest priority while sample plays */
while ((gs_sound_check()) && (!stop)) /* wait for all channels idle */
chkabort(); /* and check for abort signal */
gs_task_prio(old_prio);
gs_stop_sound(CHANNEL0); /* stop all sounds (if still active) */
gs_close_sound(); /* shut down sound system */
gs_free_sound(&sample); /* release sound data when done */
gs_close_libs(); /* close libs and end */
}
/***************************************************************************/
void ctrl_c(signal) /* ctrl-C handling ANSI fashion (SAS/C 6.xx) */
int signal;
{
stop=1; /* set flag to quit */
}